<template>
  <div>
    <el-container style="height: 50px;background-color:#409EFF;color:white;">
      <h1 style="text-align: center;width: 100%">进销存管理系统</h1>
    </el-container>
    <el-row>
      <el-col :span="4" style="background-color:#409EFF;height: 460px;">
        <el-menu
            active-text-color="#ffd04b"
            background-color="#409EFF"
            class="el-menu-vertical-demo"
            default-active="2"
            text-color="#fff"
        >
          <el-sub-menu index="1" v-if="loginUser.grade == '采购员' || loginUser.grade == '超级管理员'">
            <template #title>
              <el-icon><location /></el-icon>
              <span>采购管理</span>
            </template>
            <el-menu-item index="1-1"  @click="$router.push('/index/buy')">采购入库</el-menu-item>
            <el-menu-item index="1-2"  @click="$router.push('/index/buyInfo')">采购信息查询</el-menu-item>
          </el-sub-menu>

          <el-sub-menu index="2" v-if="loginUser.grade == '销售员' || loginUser.grade == '超级管理员'">
            <template #title>
              <el-icon><location /></el-icon>
              <span>销售管理</span>
            </template>
            <el-menu-item index="2-1"  @click="$router.push('/index/sell')">销售管理</el-menu-item>
            <el-menu-item index="2-2"  @click="$router.push('/index/sellInfo')">销售信息查询</el-menu-item>
          </el-sub-menu>

          <el-sub-menu index="3"  v-if="loginUser.grade == '库管员' || loginUser.grade == '超级管理员'">
            <template #title>
              <el-icon><location /></el-icon>
              <span>库存管理</span>
            </template>
            <el-menu-item index="3-1" @click="$router.push('/index/save')">库存一览</el-menu-item>
          </el-sub-menu>

          <el-sub-menu index="4"  v-if="loginUser.grade == '超级管理员'">
            <template #title>
              <el-icon><location /></el-icon>
              <span>统计信息</span>
            </template>
            <el-menu-item index="4-1" @click="$router.push('/index/sellCount')">销售统计</el-menu-item>
          </el-sub-menu>

          <el-sub-menu index="5">
            <template #title>
              <el-icon><location /></el-icon>
              <span>用户管理</span>
            </template>
            <el-menu-item index="5-1" v-if="loginUser.grade == '超级管理员'" @click="$router.push('/index/user')">用户管理</el-menu-item>
            <el-menu-item index="5-2" @click="$router.push('/index/updatePwd')">修改密码</el-menu-item>
          </el-sub-menu>

        </el-menu>

      </el-col>
      <el-col :span="20">
        <router-view></router-view>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loginUser:{} //登陆用户
    }
  },
  created() {
    var loginInfo = sessionStorage.getItem("loginUser");
    if(loginInfo != null) {
      this.loginUser = JSON.parse(loginInfo);
    }
  }
}
</script>

<style scoped>

</style>